import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 佣金记录信息 */
export interface BrokerageRecord {
          id: number; // 编号
          userId?: number; // 用户编号
          bizId?: string; // 业务编号
          bizType?: number; // 业务类型：1-订单，2-提现
          title?: string; // 标题
          price?: number; // 金额
          totalPrice?: number; // 当前总佣金
          description?: string; // 说明
          status?: number; // 状态：0-待结算，1-已结算，2-已取消
          frozenDays?: number; // 冻结时间（天）
          unfreezeTime: string | Dayjs; // 解冻时间
          sourceUserLevel?: number; // 来源用户等级
          sourceUserId?: number; // 来源用户编号
          tableName: string; // 数据来源
          tableId: number; // 数据来源ID
  }

// 佣金记录 API
export const BrokerageRecordApi = {
  // 查询佣金记录分页
  getBrokerageRecordPage: async (params: any) => {
    return await request.get({ url: `/trade/brokerage-record/page`, params })
  },

  // 查询佣金记录详情
  getBrokerageRecord: async (id: number) => {
    return await request.get({ url: `/trade/brokerage-record/get?id=` + id })
  },

  // 新增佣金记录
  createBrokerageRecord: async (data: BrokerageRecord) => {
    return await request.post({ url: `/trade/brokerage-record/create`, data })
  },

  // 修改佣金记录
  updateBrokerageRecord: async (data: BrokerageRecord) => {
    return await request.put({ url: `/trade/brokerage-record/update`, data })
  },

  // 删除佣金记录
  deleteBrokerageRecord: async (id: number) => {
    return await request.delete({ url: `/trade/brokerage-record/delete?id=` + id })
  },

  /** 批量删除佣金记录 */
  deleteBrokerageRecordList: async (ids: number[]) => {
    return await request.delete({ url: `/trade/brokerage-record/delete-list?ids=${ids.join(',')}` })
  },

  // 导出佣金记录 Excel
  exportBrokerageRecord: async (params) => {
    return await request.download({ url: `/trade/brokerage-record/export-excel`, params })
  }
}